package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.DomainCertificateService;
import com.yswy.backstage.service.TgMediaAccountService;
import com.yswy.backstage.service.impl.TgMediaAccountServiceImpl;
import com.yswy.domain.entity.Domain;
import com.yswy.domain.entity.DomainCertificate;
import com.yswy.domain.entity.tf.TgMediaAccount;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.DomainCertificateAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.TgMediaAccountAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/tgMediaAccount")
@Api(tags = "媒体账号")
public class TgMediaAccountController {

    @Autowired
    private TgMediaAccountService tgMediaAccountService;


    @PostMapping("/listTgMediaAccount")
    @ApiOperation(value = "投放账户列表")
    public Page<TgMediaAccount> listTgMediaAccount(@RequestBody BaseFilter req,
                                   HttpServletRequest request) {
        return tgMediaAccountService.listTgMediaAccount(req);
    }

    @GetMapping("/isExist")
    @ApiOperation(value = "判断投放账户是否存在")
    public Boolean isExist(@RequestParam(value = "accountNum") String accountNum,
                        HttpServletRequest request) {
        return tgMediaAccountService.isExist(accountNum);
    }


    @PostMapping("/addTgMediaAccount")
    @ApiOperation(value = "添加投放账户")
    public void addTgMediaAccount(@RequestBody @Validated(BaseReqVO.CREATE.class) TgMediaAccountAddOrUpdate req, HttpServletRequest request) {
        tgMediaAccountService.addOrUpadteTgMediaAccount(req);
    }


    @PostMapping("/upadteTgMediaAccount")
    @ApiOperation(value = "修改投放账户")
    public void upadteTgMediaAccount(@RequestBody @Validated(BaseReqVO.UPDATE.class) TgMediaAccountAddOrUpdate req, HttpServletRequest request) {
        tgMediaAccountService.addOrUpadteTgMediaAccount(req);
    }


    @GetMapping("/delTgMediaAccount")
    @ApiOperation(value = "删除投放账户")
    public void delTgMediaAccount(@RequestParam(value = "softnessId") Long softnessId,
                                   HttpServletRequest request) {
        tgMediaAccountService.delTgMediaAccount(softnessId);
    }


}
